<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $record_id 发送记录ID
 * @property int $robot_id 微号ID
 * @property int $room_id 群ID
 * @property string $to_id 
 * @property int $msg_server_id 消息ID
 * @property int $status 状态：0=转播中 1=转播成功 2=转播失败
 * @property string $fail_msg 失败原因
 * @property string $completed_at 完成时间
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property-read null|ChRobot $robot 
 * @property-read null|ChRoom $room 
 * @property-read null|ChRoomBroadcastRecord $record 
 */
class ChRoomBroadcastRecordTarget extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_room_broadcast_record_targets';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'record_id', 'robot_id', 'room_id', 'to_id', 'msg_server_id', 'status', 'fail_msg', 'completed_at', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'record_id' => 'integer', 'robot_id' => 'integer', 'room_id' => 'integer', 'msg_server_id' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function robot(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChRobot::class, 'id', 'robot_id');
    }

    public function room(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChRoom::class, 'id', 'room_id');
    }

    public function record(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChRoomBroadcastRecord::class, 'id', 'record_id');
    }
}
